package com.gcxy.springmybatisplustest.domain.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApiResponse<T> {
    private Integer code;//业务状态码  200-成功  500-失败
    private String message;//提示信息
    private T data;//响应数据

    public static <E> ApiResponse <E> success(E data){
        return new ApiResponse<>(200,"请求成功",data);
    }

    public static ApiResponse success(){
        return new ApiResponse(200,"请求成功",null);
    }

    public static ApiResponse error(String message){
        return new ApiResponse(500,message,null);
    }

    public static ApiResponse error(String message,Integer code){
        return new ApiResponse(code,message,null);
    }
}
